@extends('layouts.back_stage')
@section('content')
    <style>
        .tableBg{padding:30px;background:#fff;}
        .shopBg{background:#fff;overflow: hidden;margin:20px 0 10px 0;}
        .pagination-box{text-align: center;box-sizing:border-box;margin-top:20px;}
        .input-item{width:200px;padding-right: 0;}
        ::-webkit-scrollbar {height: 8px;}
        .el-table__footer-wrapper tbody td, .el-table__header-wrapper tbody td{color:red;}
        .el-select .el-input .el-select__caret.el-input__icon{line-height:22px;}
        .el-table thead.is-group th{padding:0 !important;}
        .el-checkbox+.el-checkbox{margin-left: 20px !important;}
        [v-cloak] {display: none;}
    </style>
    <div class="container">
        <div style="padding:20px 20px 20px 0;overflow:hidden;"><h3 style="float:left;">订货系统</h3></div>
        <!-- 主体-->
        <div class="page-body">
            <div class="row app" id="shopInfos" v-cloak>
                <div class="col-md-12 row row-table-box">
                    <div class="shopBg">
                        <div class="row" style="margin-top:10px;padding:26px 30px;min-height:90px;background:#fff;">
                            <label>公司：</label>
                            <el-select v-model="company_id" filterable placeholder="请选择公司" size="small" style="width:200px;">
                                <el-option v-for="item in options1" :key="item.id" :label="item.company_name" :value="item.id"></el-option>
                            </el-select>

                            {{--<label>时间：</label>--}}
                            {{--<el-date-picker v-model="getDatas" @change="getTime" type="daterange" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" size="small"></el-date-picker>--}}
                            <el-button type="primary" size="small" @click="sou('reset')">搜索</el-button>
                            <el-button type="primary" size="small" @click="resetSou('reset')">重置</el-button>
                        </div>
                    </div>
                    <div class="tableBg" style="margin-top:10px;position:relative;">
                        {{--<el-popover placement="bottom" width="400" trigger="click" v-model="visible" style="position:absolute;right:50px;top:30px;z-index:10000;">--}}
                            {{--<label style="margin:10px 0;">已选条件</label>--}}
                            {{--<el-checkbox-group v-model="xuanList">--}}
                                {{--<el-checkbox v-for="city1 in cities1" :label="city1" :key="city1">@{{city1}}</el-checkbox>--}}
                            {{--</el-checkbox-group>--}}
                            {{--<label style="margin:10px 0;">可选条件</label>--}}
                            {{--<el-checkbox-group v-model="checkList">--}}
                                {{--<el-checkbox v-for="city2 in cities2" :label="city2" :key="city2">@{{city2}}</el-checkbox>--}}
                            {{--</el-checkbox-group>--}}
                            {{--<el-button type="primary" size="small" style="float: right;margin-top: 20px;" @click="fuXuan">确定</el-button>--}}
                            {{--<el-button type="primary" size="small" @click="visible = false" style="float: right;margin-top: 20px;margin-right:20px;">取消</el-button>--}}
                            {{--<el-button type="text" slot="reference">更多条件<i class="el-icon-arrow-down el-icon--right"></i></el-button>--}}
                        {{--</el-popover>--}}
                        <el-tabs v-model="activeName2" type="border-card" @tab-click="handleClick">
                            <el-tab-pane label="按款明细" name="first">
                                <el-table :data="girardDetails" max-height="510" size="mini" style="width: 100%;" border :summary-method="getSummaries1" show-summary>
                                    <el-table-column prop="loop" label="序号" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_1" label="大类" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_2" label="中类" width="75" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_3" label="小类" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="brand" label="品牌" width="90" :resizable='false'></el-table-column>
                                    <el-table-column prop="girard" label="款号" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="color" label="颜色" width="75" :resizable='false'></el-table-column>
                                    <el-table-column prop="year" label="年份" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="season" label="季节" width="50" :resizable='false'></el-table-column>

                                    <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="disPrice" label="折扣价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="discount" label="折扣" width="85" :resizable='false'></el-table-column>

                                    <el-table-column v-for="item in sizeGr"  :label="item.key76" width="70" :resizable='false'>
                                        <el-table-column :label="item.key75" width="70" :resizable='false'>
                                            <el-table-column :label="item.key79" width="70" :resizable='false'>
                                                <el-table-column :label="item.key154" width="70" :resizable='false'>
                                                    <el-table-column :label="item.key146" width="70" :resizable='false'>
                                                        <el-table-column :label="item.key161" width="70" :resizable='false'>
                                                            <el-table-column :label="item.key77" width="70" :resizable='false'>
                                                                <el-table-column :prop="item.key_0" :label="item.key140" width="70" :resizable='false'></el-table-column>
                                                            </el-table-column>
                                                        </el-table-column>
                                                    </el-table-column>
                                                </el-table-column>
                                            </el-table-column>
                                        </el-table-column>
                                    </el-table-column>

                                    <el-table-column prop="count" label="订货量/件" width="85" :resizable='false'></el-table-column>
                                    <el-table-column prop="disCount" label="订货额/元" align="right" width="120" :resizable='false'></el-table-column>
                                    <el-table-column prop="cardCount" label="订货吊牌额/元" align="right" width="120" :resizable='false'></el-table-column>
                                </el-table>
                                <div class="pagination-box">
                                    <el-pagination @size-change="handleSizeChange1" :page-sizes="[10,50,100,200]" :page-size="10" @current-change="changePageSkip1" :current-page.sync="currentPage1" :total="total1" layout="sizes,prev, pager, next" background></el-pagination>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="按客户按款明细" name="second">
                                <el-table :data="girardPeople" max-height="510"  size="mini" style="width: 100%;" border :summary-method="getSummaries2" show-summary>
                                    <el-table-column prop="loop" label="序号" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="client_name" label="客户" width="140" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_1" label="大类" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_3" label="小类" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="brand" label="品牌" width="90" :resizable='false'></el-table-column>
                                    <el-table-column prop="girard" label="款号" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="color" label="颜色" width="75" :resizable='false'></el-table-column>
                                    <el-table-column prop="year" label="年份" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="season" label="季节" width="50" :resizable='false'></el-table-column>

                                    <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="disPrice" label="折扣价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="discount" label="折扣" width="85" :resizable='false'></el-table-column>

                                    <el-table-column v-for="item in sizeGr"  :label="item.key76" width="70" :resizable='false'>
                                        <el-table-column :label="item.key75" width="70" :resizable='false'>
                                            <el-table-column :label="item.key79" width="70" :resizable='false'>
                                                <el-table-column :label="item.key154" width="70" :resizable='false'>
                                                    <el-table-column :label="item.key146" width="70" :resizable='false'>
                                                        <el-table-column :label="item.key161" width="70" :resizable='false'>
                                                            <el-table-column :label="item.key77" width="70" :resizable='false'>
                                                                <el-table-column :prop="item.key_0" :label="item.key140" width="70" :resizable='false'></el-table-column>
                                                            </el-table-column>
                                                        </el-table-column>
                                                    </el-table-column>
                                                </el-table-column>
                                            </el-table-column>
                                        </el-table-column>
                                    </el-table-column>

                                    <el-table-column prop="count" label="订货量/件" width="85" :resizable='false'></el-table-column>
                                    <el-table-column prop="disCount" label="订货额/元" align="right" width="120" :resizable='false'></el-table-column>
                                    <el-table-column prop="cardCount" label="订货吊牌额/元" align="right" width="120" :resizable='false'></el-table-column>
                                </el-table>
                                <div class="pagination-box">
                                    <el-pagination @size-change="handleSizeChange2" :page-sizes="[10,50,100,200]" :page-size="10" @current-change="changePageSkip2" :current-page.sync="currentPage2" :total="total2" layout="sizes,prev, pager, next" background></el-pagination>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="分客户按款剩余" name="third">
                                <el-table :data="surplusInfo" max-height="510"  size="mini" style="width: 100%;" border :summary-method="getSummaries3" show-summary>
                                    <el-table-column prop="loop" label="序号" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="client_name" label="客户" width="140" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_2" label="中类" width="75" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_3" label="小类" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="brand" label="品牌" width="90" :resizable='false'></el-table-column>
                                    <el-table-column prop="girard" label="款号" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="color" label="颜色" width="75" :resizable='false'></el-table-column>
                                    <el-table-column prop="year" label="年份" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="season" label="季节" width="50" :resizable='false'></el-table-column>

                                    <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="disPrice" label="折扣价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="discount" label="折扣" width="85" :resizable='false'></el-table-column>

                                    <el-table-column v-for="item in sizeGr"  :label="item.key76" width="70" :resizable='false'>
                                        <el-table-column :label="item.key75" width="70" :resizable='false'>
                                            <el-table-column :label="item.key79" width="70" :resizable='false'>
                                                <el-table-column :label="item.key154" width="70" :resizable='false'>
                                                    <el-table-column :label="item.key146" width="70" :resizable='false'>
                                                        <el-table-column :label="item.key161" width="70" :resizable='false'>
                                                            <el-table-column :label="item.key77" width="70" :resizable='false'>
                                                                <el-table-column :prop="item.key_0" :label="item.key140" width="70" :resizable='false'></el-table-column>
                                                            </el-table-column>
                                                        </el-table-column>
                                                    </el-table-column>
                                                </el-table-column>
                                            </el-table-column>
                                        </el-table-column>
                                    </el-table-column>

                                    <el-table-column prop="count" label="剩余总量/件" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="disCount" label="剩余订货额/元" align="right" width="120" :resizable='false'></el-table-column>
                                    <el-table-column prop="cardCount" label="剩余订货吊牌额/元" align="right" width="135" :resizable='false'></el-table-column>
                                </el-table>
                                <div class="pagination-box">
                                    <el-pagination @size-change="handleSizeChange3" :page-sizes="[10,50,100,200]" :page-size="10" @current-change="changePageSkip3" :current-page.sync="currentPage3" :total="total3" layout="sizes,prev, pager, next" background></el-pagination>
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="订货清单" name="fourth">
                                <el-table :data="orderInfo" max-height="510"  size="mini" style="width: 100%;" border :summary-method="getSummaries4" show-summary>
                                    <el-table-column prop="loop" label="序号" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="order_num" label="订单号" width="120" :resizable='false'></el-table-column>
                                    <el-table-column prop="client_name" label="客户" width="140" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_1" label="大类" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="cate_3" label="小类" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="brand" label="品牌" width="90" :resizable='false'></el-table-column>
                                    <el-table-column prop="girard" label="款号" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="color" label="颜色" width="75" :resizable='false'></el-table-column>
                                    <el-table-column prop="year" label="年份" width="50" :resizable='false'></el-table-column>
                                    <el-table-column prop="season" label="季节" width="50" :resizable='false'></el-table-column>

                                    <el-table-column prop="price" label="吊牌价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="disPrice" label="折扣价/元" align="right" width="130" :resizable='false'></el-table-column>
                                    <el-table-column prop="discount" label="折扣" width="85" :resizable='false'></el-table-column>

                                    <el-table-column v-for="item in sizeGr"  :label="item.key76" width="70" :resizable='false'>
                                        <el-table-column :label="item.key75" width="70" :resizable='false'>
                                            <el-table-column :label="item.key79" width="70" :resizable='false'>
                                                <el-table-column :label="item.key154" width="70" :resizable='false'>
                                                    <el-table-column :label="item.key146" width="70" :resizable='false'>
                                                        <el-table-column :label="item.key161" width="70" :resizable='false'>
                                                            <el-table-column :label="item.key77" width="70" :resizable='false'>
                                                                <el-table-column :prop="item.key_0" :label="item.key140" width="70" :resizable='false'></el-table-column>
                                                            </el-table-column>
                                                        </el-table-column>
                                                    </el-table-column>
                                                </el-table-column>
                                            </el-table-column>
                                        </el-table-column>
                                    </el-table-column>

                                    <el-table-column prop="count" label="订货量/件" width="100" :resizable='false'></el-table-column>
                                    <el-table-column prop="disCount" label="订货额/元" align="right" width="120" :resizable='false'></el-table-column>
                                    <el-table-column prop="cardCount" label="订货吊牌额/元" align="right" width="135" :resizable='false'></el-table-column>
                                </el-table>
                                <div class="pagination-box">
                                    <el-pagination @size-change="handleSizeChange4" :page-sizes="[10,50,100,200]" :page-size="10" @current-change="changePageSkip4" :current-page.sync="currentPage4" :total="total4" layout="sizes,prev, pager, next" background></el-pagination>
                                </div>
                            </el-tab-pane>
                        </el-tabs>
                    </div>
                </div>
            </div>
        </div>
        <!-- /主体-->
    </div>
    <script>
        new Vue({
            el: '#shopInfos',
            data:{
                sizeGr:[],//尺码信息

//                visible:false,//复选框显示隐藏
//                cities1:[],//数据
//                xuanList:[],//已选复选框
//                cities2:['年份','季节','品牌','类别','客户'],//数据
//                checkList:[],//未选复选框


                activeName2: 'first',
                company_id:'',//公司
                sale_season:'',//销售季节
                girard:'',//款号
//                getDatas:'', //起止时间
//                created_at:'', //起止时间存储变量


                girardDetails:[], //按款明细
                total1:1,  //table总条数
                page1:10,//每页多少条
                currentPage1:1, //table当前页数
                girardNum1:'',//款号种类合计

                girardPeople:[], //按客户按款明细
                total2:1,  //table总条数
                page2:10,//每页多少条
                currentPage2:1, //table当前页数
                girardNum2:'',//款号种类合计

                surplusInfo:[],//分客户按剩余
                total3:1,  //table总条数
                page3:10,//每页多少条
                currentPage3:1, //table当前页数
                girardNum3:'',//款号种类合计

                orderInfo:[],//订货清单
                total4:1,  //table总条数
                page4:10,//每页多少条
                currentPage4:1, //table当前页数
                girardNum4:'',//款号种类合计


                options1: [], //公司
            },
            mounted(){
                this.common();
                this.baseInfo();
                this.grabble1();
            },
            methods:{
                /*筛选*/
//                fuXuan(){
//                    console.log(this.xuanList)
//                    this.cities1=this.checkList;
//                    this.xuanList=this.checkList;
//
//                    this.cities1=this.xuanList;
//                },
                /*尺码数据*/
                common(){
                    var that=this;
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/distribution/sizeGroupHead',
                        data: {
                            type:1,
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.sizeGr=data.content.vertical;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*基本信息*/
                baseInfo(){
                    var that=this;
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/distribution/analysis-infos',
                        data: {
                            company:-1,
                        },
                        success: function (data) {
                            //console.log(data);
                            if(data.result.success){
                                that.company_id=data.content.company_id;
                                that.options1 = data.content.data;
                            }else{
                                that.$notify.error({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                });
                            }
                        }
                    });
                },
                /*时间*/
//                getTime(date){
//                    if(date==null){
//                        this.getDatas='';
//                        this.created_at ='';
//                    }else{
//                        this.getDatas=date;
//                        this.created_at =date[0]+' - '+date[1];
//                    }
//                },
                /*搜索*/
                sou(){
                    if(this.activeName2=='first'){
                        this.grabble1('reset');
                    }else if(this.activeName2=='second'){
                        this.grabble2('reset');
                    }else if(this.activeName2=='third'){
                        this.grabble3('reset');
                    }else if(this.activeName2=='fourth'){
                        this.grabble4('reset');
                    }
                },
                /*重置*/
                resetSou(){
                    this.company_id=1;
                    if(this.activeName2=='first'){
                        this.grabble1('reset');
                    }else if(this.activeName2=='second'){
                        this.grabble2('reset');
                    }else if(this.activeName2=='third'){
                        this.grabble3('reset');
                    }else if(this.activeName2=='fourth'){
                        this.grabble4('reset');
                    }
                },
//-----------------------------------
                /*按款明细列表*/
                grabble1(type){
                    var that = this;
                    let skip;
                    if(type == 'reset'){
                        skip = 0;
                    }else{
                        skip = that.currentPage1-1;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/order-inquire/filter-analisis',
                        data: {
                            skip:skip,
                            page1:that.page1,
                            company_id:that.company_id,
                            type:1,
                        },
                        success: function (data) {
                            console.log(data);
                            if(data.result.success){
                                var opt=[];
                                let girardArr=[];
                                let i = 0;
                                for(var value of data.content.data){
                                    if(girardArr.indexOf(value.girard)==-1){
                                        girardArr.push(value.girard)
                                    };
                                    var cvs=0;
                                    for(var cv=0;cv<value.nums.length;cv++){
                                        if(value.nums[cv]==''){
                                            value.nums[cv]=0;
                                        }
                                        cvs+=Number(value.nums[cv]);
                                    }
                                    var oneNum=0;
                                    var twoNum=0;
                                    if(value.nums.length==9 && value.price.indexOf("/")!=-1){
                                        for(var cc=0;cc<value.nums.length;cc++){
                                            if(value.nums[cc]==''){
                                                value.nums[cc]=0;
                                            }
                                            if(cc<7){
                                                oneNum+=Number(value.nums[cc]);
                                            }else{
                                                twoNum+=Number(value.nums[cc]);
                                            }
                                        }
                                    }
                                    i++;
                                    opt.push({
                                        'id':value.id,

                                        'loop':i+(Number(that.page1)*skip),
                                        'cate_1':value.cate_1,
                                        'cate_2':value.cate_2,
                                        'cate_3':value.cate_3,
                                        'brand':value.brand,
                                        'girard':value.girard,
                                        'color':value.color,
                                        'year':value.year,
                                        'season':value.season,
                                        'price':value.price,
                                        'disPrice':value.discount_price,
                                        'discount':value.discount,
                                        'size_group':value.size_group,
                                        'num':value.nums,
                                        'count':cvs,
                                        'disCount':that.getCou( value.discount_price , oneNum , twoNum , cvs),
                                        'cardCount':that.getCou(value.price , oneNum , twoNum , cvs),
                                    })
                                }
                                that.girardNum1=girardArr.length;
                                that.girardDetails = opt;
                                that.currentPage1 = data.content.skip;
                                that.total1 = data.content.total;
                            }else{
                                that.$notify({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                    duration: 0
                                });
                            }
                        }
                    });
                },
                /*总折扣,总金额*/
                getCou(money,n1,n2,n3){
                    if(money.indexOf("/")!=-1){
                        let priArr=money.split("/");
                        let disOne=(priArr[0]*n1);
                        let disTwo=(priArr[1]*n2);
                        return (Number(disOne) + Number(disTwo)).toFixed(2);
                    }else{
                        return (money*n3).toFixed(2);
                    }
                },
                /*按款明细重置*/
                reset1(){
                    this.grabble1('reset');
                },
                /*按款明细每页条数*/
                handleSizeChange1(val) {
                    this.page1=val;
                    this.grabble1('reset');
                    //console.log(`每页 ${val} 条`);
                },
                /*按款明细分页*/
                changePageSkip1(val){
                    //console.log(val);
                    this.currentPage1 = val;
                    this.grabble1();
                },
                /*按款明细合计*/
                getSummaries1(param) {
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'girard':
                                sums[index] = that.girardNum1;
                                break;
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return prev + curr;
                                    } else {
                                        return prev;
                                    }
                                }, 0);
                                break;
                            case 'disCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            case 'cardCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },
//-----------------------------------
                /*按客户按款明细列表*/
                grabble2(type){
                    var that = this;
                    let skip;
                    if(type == 'reset'){
                        skip = 0;
                    }else{
                        skip = that.currentPage2-1;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/order-inquire/filter-analisis',
                        data: {
                            skip:skip,
                            page2:that.page2,
                            company_id:that.company_id,
                            type:2,
                        },
                        success: function (data) {
                            console.log(data);
                            if(data.result.success){
                                var opt=[];
                                let girardArr=[];
                                let i = 0;
                                for(var value of data.content.data){
                                    if(girardArr.indexOf(value.girard)==-1){
                                        girardArr.push(value.girard)
                                    };
                                    var cvs=0;
                                    for(var cv=0;cv<value.nums.length;cv++){
                                        if(value.nums[cv]==''){
                                            value.nums[cv]=0;
                                        }
                                        cvs+=Number(value.nums[cv]);
                                    }
                                    var oneNum=0;
                                    var twoNum=0;
                                    if(value.nums.length==9 && value.price.indexOf("/")!=-1){
                                        for(var cc=0;cc<value.nums.length;cc++){
                                            if(value.nums[cc]==''){
                                                value.nums[cc]=0;
                                            }
                                            if(cc<7){
                                                oneNum+=Number(value.nums[cc]);
                                            }else{
                                                twoNum+=Number(value.nums[cc]);
                                            }
                                        }
                                    }
                                    i++;
                                    opt.push({
                                        'id':value.id,
                                        'loop':i+(Number(that.page2)*skip),
                                        'client_name':value.client_name,
                                        'cate_1':value.cate_1,
                                        'cate_3':value.cate_3,
                                        'brand':value.brand,
                                        'girard':value.girard,
                                        'color':value.color,
                                        'year':value.year,
                                        'season':value.season,
                                        'price':value.price,
                                        'disPrice':value.discount_price,
                                        'discount':value.discount,
                                        'size_group':value.size_group,
                                        'num':value.nums,
                                        'count':cvs,
                                        'disCount':that.getCou( value.discount_price , oneNum , twoNum , cvs),
                                        'cardCount':that.getCou(value.price , oneNum , twoNum , cvs),

                                    })
                                }
                                that.girardNum2=girardArr.length;
                                that.girardPeople = opt;
                                that.currentPage2 = data.content.skip;
                                that.total2 = data.content.total;
                            }else{
                                that.$notify({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                    duration: 0
                                });
                            }
                        }
                    });
                },
                /*按客户按款明细重置*/
                reset2(){
                    this.grabble2('reset');
                },
                /*按客户按款每页条数*/
                handleSizeChange2(val) {
                    this.page2=val;
                    this.grabble2('reset');
                    //console.log(`每页 ${val} 条`);
                },
                /*按客户按款分页*/
                changePageSkip2(val){
                    //console.log(val);
                    this.currentPage2 = val;
                    this.grabble2();
                },
                /*按款汇总合计*/
                getSummaries2(param){
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'girard':
                                sums[index] = that.girardNum2;
                                break;
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return prev + curr;
                                    } else {
                                        return prev;
                                    }
                                }, 0);
                                break;
                            case 'disCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            case 'cardCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },
//-----------------------------------
                /*分客户按款剩余列表*/
                grabble3(type){
                    var that = this;
                    let skip;
                    if(type == 'reset'){
                        skip = 0;
                    }else{
                        skip = that.currentPage3-1;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/order-inquire/filter-analisis',
                        data: {
                            skip:skip,
                            page3:that.page3,
                            company_id:that.company_id,
                            type:3,
                        },
                        success: function (data) {
                            console.log(data);
                            if(data.result.success){
                                var opt=[];
                                let girardArr=[];
                                let i = 0;
                                for(var value of data.content.data){
                                    if(girardArr.indexOf(value.girard)==-1){
                                        girardArr.push(value.girard)
                                    };
                                    var cvs=0;
                                    for(var cv=0;cv<value.nums.length;cv++){
                                        if(value.nums[cv]==''){
                                            value.nums[cv]=0;
                                        }
                                        cvs+=Number(value.nums[cv]);
                                    }
                                    var oneNum=0;
                                    var twoNum=0;
                                    if(value.nums.length==9 && value.price.indexOf("/")!=-1){
                                        for(var cc=0;cc<value.nums.length;cc++){
                                            if(value.nums[cc]==''){
                                                value.nums[cc]=0;
                                            }
                                            if(cc<7){
                                                oneNum+=Number(value.nums[cc]);
                                            }else{
                                                twoNum+=Number(value.nums[cc]);
                                            }
                                        }
                                    }
                                    i++;
                                    opt.push({
                                        'id':value.id,
                                        'loop':i+(Number(that.page3)*skip),
                                        'client_name':value.client_name,
                                        'cate_2':value.cate_2,
                                        'cate_3':value.cate_3,
                                        'brand':value.brand,
                                        'girard':value.girard,
                                        'color':value.color,
                                        'year':value.year,
                                        'season':value.season,
                                        'price':value.price,
                                        'disPrice':value.discount_price,
                                        'discount':value.discount,
                                        'size_group':value.size_group,
                                        'num':value.nums,
                                        'count':cvs,
                                        'disCount':that.getCou( value.discount_price , oneNum , twoNum , cvs),
                                        'cardCount':that.getCou(value.price , oneNum , twoNum , cvs),

                                    })
                                }
                                that.girardNum3=girardArr.length;
                                that.surplusInfo = opt;
                                that.currentPage3 = data.content.skip;
                                that.total3 = data.content.total;
                            }else{
                                that.$notify({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                    duration: 0
                                });
                            }
                        }
                    });
                },
                /*分客户按款剩余重置*/
                reset3(){
                    this.grabble3('reset');
                },
                /*分客户按款剩余每页条数*/
                handleSizeChange3(val) {
                    this.page3=val;
                    this.grabble3('reset');
                    //console.log(`每页 ${val} 条`);
                },
                /*分客户按款剩余分页*/
                changePageSkip3(val){
                    //console.log(val);
                    this.currentPage3 = val;
                    this.grabble3();
                },
                /*分客户按款剩余合计*/
                getSummaries3(param){
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'girard':
                                sums[index] = that.girardNum3;
                                break;
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return prev + curr;
                                    } else {
                                        return prev;
                                    }
                                }, 0);
                                break;
                            case 'disCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            case 'cardCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },
//------------------------------------
                /*订货清单列表*/
                grabble4(type){
                    var that = this;
                    let skip;
                    if(type == 'reset'){
                        skip = 0;
                    }else{
                        skip = that.currentPage4-1;
                    }
                    $.ajax({
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                        },
                        type: 'post',
                        url: '/order-inquire/filter-analisis',
                        data: {
                            skip:skip,
                            page4:that.page4,
                            company_id:that.company_id,
                            type:4,
                        },
                        success: function (data) {
                            console.log(data);
                            if(data.result.success){
                                var opt=[];
                                let girardArr=[];
                                let i = 0;
                                for(var value of data.content.data){
                                    if(girardArr.indexOf(value.girard)==-1){
                                        girardArr.push(value.girard)
                                    };
                                    var cvs=0;
                                    for(var cv=0;cv<value.nums.length;cv++){
                                        if(value.nums[cv]==''){
                                            value.nums[cv]=0;
                                        }
                                        cvs+=Number(value.nums[cv]);
                                    }
                                    var oneNum=0;
                                    var twoNum=0;
                                    if(value.nums.length==9 && value.price.indexOf("/")!=-1){
                                        for(var cc=0;cc<value.nums.length;cc++){
                                            if(value.nums[cc]==''){
                                                value.nums[cc]=0;
                                            }
                                            if(cc<7){
                                                oneNum+=Number(value.nums[cc]);
                                            }else{
                                                twoNum+=Number(value.nums[cc]);
                                            }
                                        }
                                    }
                                    i++;
                                    opt.push({
                                        'id':value.id,
                                        'loop':i+(Number(that.page4)*skip),
                                        'order_num':value.order_num,
                                        'client_name':value.client_name,
                                        'cate_1':value.cate_1,
                                        'cate_3':value.cate_3,
                                        'brand':value.brand,
                                        'girard':value.girard,
                                        'color':value.color,
                                        'year':value.year,
                                        'season':value.season,
                                        'price':value.price,
                                        'disPrice':value.discount_price,
                                        'discount':value.discount,
                                        'size_group':value.size_group,
                                        'num':value.nums,
                                        'count':cvs,
                                        'disCount':that.getCou( value.discount_price , oneNum , twoNum , cvs),
                                        'cardCount':that.getCou(value.price , oneNum , twoNum , cvs),

                                    })
                                }
                                that.girardNum4=girardArr.length;
                                that.orderInfo = opt;
                                that.currentPage4 = data.content.skip;
                                that.total4 = data.content.total;
                            }else{
                                that.$notify({
                                    title: '提示',
                                    message: data.result.errorMsg,
                                    duration: 0
                                });
                            }
                        }
                    });
                },
                /*订货清单重置*/
                reset4(){
                    this.grabble4('reset');
                },
                /*订货清单每页条数*/
                handleSizeChange4(val) {
                    this.page4=val;
                    this.grabble4('reset');
                    //console.log(`每页 ${val} 条`);
                },
                /*订货清单分页*/
                changePageSkip4(val){
                    //console.log(val);
                    this.currentPage4 = val;
                    this.grabble4();
                },
                /*订货清单合计*/
                getSummaries4(param){
                    var that=this;
                    const { columns, data } = param;
                    const sums = [];
                    columns.forEach((column, index) => {
                        if (index === 0) {
                            sums[index] = '合计';
                            return;
                        }
                        const values = data.map(item => Number(item[column.property]));
                        switch (column.property) {
                            case 'girard':
                                sums[index] = that.girardNum4;
                                break;
                            case 'count':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return prev + curr;
                                    } else {
                                        return prev;
                                    }
                                }, 0);
                                break;
                            case 'disCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            case 'cardCount':
                                sums[index] = values.reduce((prev, curr) => {
                                    const value = Number(curr);
                                    if (!isNaN(value)) {
                                        return ( parseFloat(prev) + parseFloat(curr) ).toFixed(2);
                                    } else {
                                        return parseFloat(prev).toFixed(2);
                                    }
                                }, 0);
                                break;
                            default:
                                break;
                        }
                    });
                    return sums
                },


                /*点击切换tab*/
                handleClick(tab, event) {
                    if(tab.name=='first'){
                        this.grabble1('reset');
                    }else if(tab.name=='second'){
                        this.grabble2('reset');
                    }else if(tab.name=='third'){
                        this.grabble3('reset');
                    }else if(tab.name=='fourth'){
                        this.grabble4('reset');
                    }
                },
            },
        });
    </script>
@endsection
